// void, Obj This

Unit this;
int p, per_health;

Sleep(1240+rand(GetConst("RandTimeStart"))+GetConst("AddTimeStart"));

this = This.AsUnit;

while(!.IsValid) Sleep(10000); 

p = .player;
//pr("elephant_madness");
 
while(.IsValid){

	per_health = (.health+1)*100/(.maxhealth+1);
    
	if(per_health < 10){
		if(.command == "engage" 
		|| .command == "attack" 
		|| .command == "stand_position" 
		|| .command == "advance"){
		
	        if(.player != 15){
                if(.hero.IsValid)
					.DetachFrom(.hero);
                        	
				.SetPlayer(15);
                .SetSpeedFactor(160);
                .AddBonus(30,0,0,0,0);
                .Heal(1500); 
				Sleep(rand(15000)+10000);
				
                if(.IsValid){
                    .AddBonus(-30,0,0,0,0);
                    .SetSpeedFactor(100);
                    .SetPlayer(p);
					.Damage(1000);
                } 
            }       
	    }
    }
	Sleep(3000);
}
